import React, { Component } from 'react';
import { Text, View, Button, Image, Animated, Easing, Alert } from 'react-native';

export default class AnimationPage extends Component {
  constructor(props) {
    super(props);
    this.spinValue = new Animated.Value(0)
  }

  componentDidMount() {
      // this.spin()
  }

  spin () {
  this.spinValue.setValue(0)
  Animated.timing(
    this.spinValue,
    {
      toValue: 1*1000,
      duration: 1000*1000,
      easing: Easing.linear
    }
  ).start()
  }

  render() {
    const spin = this.spinValue.interpolate({
    inputRange: [0, 1000],
    outputRange: ['0deg', '360000deg']
    })
    return (
      <View style={{alignItems: 'center', margin:50}}>
      <Button
        onPress={()=>(this.spin())}
        title='start'
      />
      <Animated.Image
        style={{margin:50, width: 250, height: 250, resizeMode:'contain',transform: [{rotate: spin}]}}
        source={{uri: 'http://photocdn.sohu.com/20120128/Img333056814.jpg'}}
      />
      </View>
    );
  }
}
